package com.beans.indicator;

import com.beans.indicator.model.IndicatorModel;
import com.beans.indicator.view.AnalogIndicatorView;
import java.beans.PropertyChangeSupport;

/**
 *
 * @author Wojtek
 */
public class AnalogIndicator extends AnalogIndicatorView {

    private final static String PROP_MINVALUE = "minValue_property";
    private final static String PROP_MAXVALUE = "maxValue_property";
    private final static String PROP_MINCRITICALVALUE = "minCriticalValue_property";
    private final static String PROP_MAXCRITICALVALUE = "maxCriticalValue_property";
    private final static String PROP_VALUE = "value_property";

    PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);

    public AnalogIndicator() {
        super(new IndicatorModel());
        this.model.addObserver(this);
    }

    public void setMinValue(int minValue) {
        int oldVal = model.getMinValue();
        model.setMinValue(minValue);
        firePropertyChange(PROP_MINVALUE, oldVal, minValue);
    }

    public int getMinValue() {
        return model.getMinValue();
    }

    public void setMaxValue(int maxValue) {
        int oldVal = model.getMaxValue();
        model.setMaxValue(maxValue);
        firePropertyChange(PROP_MAXVALUE, oldVal, maxValue);
    }

    public int getMaxValue() {
        return model.getMaxValue();
    }
    
    public void setMinCriticalValue(int minCriticalValue) {
        int oldVal = model.getMinCriticalValue();
        model.setMinCriticalValue(minCriticalValue);
        firePropertyChange(PROP_MINCRITICALVALUE, oldVal, minCriticalValue);
    }

    public int getMinCriticalValue() {
        return model.getMinCriticalValue();
    }

    public void setMaxCriticalValue(int maxCriticalValue) {
        int oldVal = model.getMaxCriticalValue();
        model.setMaxCriticalValue(maxCriticalValue);
        firePropertyChange(PROP_MAXCRITICALVALUE, oldVal, maxCriticalValue);
    }
    
    public int getMaxCriticalValue() {
        return model.getMaxCriticalValue();
    }

    public void setValue(int value) {
        int oldVal = model.getValue();
        model.setValue(value);
        firePropertyChange(PROP_VALUE, oldVal, model.getValue());
    }

    public int getValue() {
        return model.getValue();
    }
}

